package com.pig4cloud.pig.common.data.methods;

import cn.hutool.core.lang.Dict;
import com.baomidou.mybatisplus.core.metadata.TableInfo;
import com.pig4cloud.pig.common.data.enums.SqlMethod;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.SqlSource;

public class InsertBatch extends BaseAbstractMethod {

    @Override
    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {

        // sql 语句
        String ifSqlValue = sqlContext(tableInfo, true, null);
        Dict ifSqlMap = new Dict().set("a", tableInfo.getAllInsertSqlColumnMaybeIf()).set("b", ifSqlValue).set("c",tableInfo.getTableName());
        // sql
        SqlSource sqlSource = sqlSource(SqlMethod.INSERT_BATCH.getSql(), modelClass, tableInfo, ifSqlMap,true,true,false);

        return insertMappedStatement(mapperClass, modelClass, getClass(), sqlSource,tableInfo);
    }

}
